<?php echo $this->Html->script(array('print')); ?>

<div class="page-header">
    <div class="icon">
        <span class="ico-layout-7"></span>
    </div>
    <h1>Recargas <small>Listado de recargas</small></h1>
</div>
<div class="row-fluid">
    <div class="span7">
        <div class="block">
            <div class="head green">
                <div class="icon"><span class="ico-layout-9"></span></div>
                <h2>Detalle de la Factura &nbsp;<?php echo date('d-m-Y'); ?></h2>
                <ul class="buttons">
                    <li><a href="#" onClick="source('table_sort_pagination');
                            return false;"><div class="icon"><span class="ico-info"></span></div></a></li>
                </ul>                                                        
            </div>  

            <div id="areaImprimir">
                <table border="1" cellspacing="2" cellpadding="2">
                    <tr>
                        <td>
                            <p align="center"><?php echo $this->Html->image('factura.png') ?></p>
                            <p align="center"><strong>NuevaTel PCS de Bolivia S.A.</strong> </br> <strong>La Paz - Bolivia</strong></p>     
                        </td>
                        <td align="center"><h2><strong>FACTURA</strong></h2></td>
                        <td><p><strong>NIT:</strong>&nbsp; 1007173022</p>
                            <p><strong>FACTURA No:</strong>&nbsp;&nbsp;<?php echo $numero_factura ?></p>
                            <p><strong>AUTORIZACION:</strong>&nbsp;&nbsp;<?php echo $autorizacion ?></p>
                            <p><strong>Codigo de Control:</strong>&nbsp;&nbsp; <?php echo $codigo_control ?></p>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3"><p><strong>&nbsp;Fecha:</strong><?php echo date('d') ?>/<?php echo date('m') ?>/20<?php echo date('y') ?></p>
                            <p><strong>&nbsp;Se&ntilde;or(es):</strong> <?php echo $nombre_cliente; ?><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NIT/CI:</strong> <?php echo $nit ?></p></td>
                    </tr>
                    <tr>
                        <td colspan="3"><table width="750" border="1" cellspacing="2" cellpadding="2">
                                <tr>
                                    <td width="122" align="center"><strong>CANTIDAD</strong></td>
                                    <td width="398" align="center"><strong>DETALLE</strong></td>
                                    <td width="202" align="center"><strong>IMPOTE</strong></td>
                                </tr>
                                <tr>
                                    <td align="center">&nbsp;1</td>
                                    <td align="center">&nbsp;Servicio Prepago Movil</td>
                                    <td align="center">&nbsp;<?php echo $monto_decimales; ?></td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td align="center"><strong>MONTO TOTAL (BS.)</strong></td>
                                    <td align="center"><strong><?php echo $monto_decimales; ?>
                                        </strong></td>
                                </tr>
                                <tr>
                                    <td colspan="3"><strong>&nbsp;&nbsp;&nbsp;&nbsp;SON: </strong><?php echo $monto_letras ?> &nbsp;&nbsp;
                                        <?php 
                                        $aux = (string) $monto_decimales;
                                        $decimal = substr( $aux, strpos( $aux, "." ) );
                                        echo $decimal*100;
                                        ?> 
                                        /100 
                                        &nbsp; Bolivianos</td>
                                </tr>
                            </table></td>
                    </tr>
                </table>
            </div>
            <tr>
                <td> 
                    <button class="btn btn-large btn-block btn-primary" type="button" href="#" id="btnImprimir">IMPRIMIR FACTURA</button>
                </td>
                <td></td>
                <td class="align-center">
                    <?php echo $this->Html->link('ATRAS  ', array('controller' => 'Clientes', 'action' => 'index'), array('class' => 'btn btn-large btn-block btn-warning')) ?>
                </td>
            </tr>

        </div> 
    </div>
</div>




<script type="text/javascript">

                        $(document).ready(function() {

                            $("#btnImprimir").click(function() {
                                //console.log('click');
                                printElem({
                                    leaveOpen: true,
                                    printMode: 'popup',
                                    overrideElementCSS: [
                                        '<?php echo $this->webroot; ?>css/imprimir.css',
                                        {href: '<?php echo $this->webroot; ?>css/imprimir.css', media: 'print'}]
                                });
                                //printElem({ overrideElementCSS: ['http://www.imprenta.com/css/printable.css'] });
                            });

                        });
                        function printElem(options) {
                            $('#areaImprimir').printElement(options);
                        }
</script>